-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[opt](kerberos) use ticket cache instead of principal+keytab on BE side #47299
Conversation
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
972fb7e
to
8c80cf5
Compare
run buildall |
TPC-H: Total hot run time: 32324 ms
|
TPC-DS: Total hot run time: 192037 ms
|
ClickBench: Total hot run time: 31.23 s
|
run buildall |
TPC-H: Total hot run time: 31973 ms
|
TPC-DS: Total hot run time: 191165 ms
|
ClickBench: Total hot run time: 31.13 s
|
TeamCity be ut coverage result: |
run buildall |
TPC-H: Total hot run time: 32501 ms
|
TPC-DS: Total hot run time: 191616 ms
|
ClickBench: Total hot run time: 30.51 s
|
run buildall |
TPC-H: Total hot run time: 32325 ms
|
TeamCity be ut coverage result: |
TPC-DS: Total hot run time: 196460 ms
|
) ### What problem does this PR solve? Related PR: #47299 Problem Summary: The master branch only support java 17+, so should remote all `JAVA_OPTS` and use `JAVA_OPTS_FOR_JDK_17`
) ### What problem does this PR solve? Related PR: #47299 Problem Summary: The master branch only support java 17+, so should remote all `JAVA_OPTS` and use `JAVA_OPTS_FOR_JDK_17`
…de (apache#47299) ### What problem does this PR solve? #### Overview Previously, BE node use principal and keytab to do the kerberos authentication. But only the modified hadoop libhdfs support authenticating in this way, the origin libhdfs only support setting kerberos ticket cache path, or use system level kerberos authentication context. This pull request introduces a comprehensive Kerberos authentication module for the BE. The module is designed to handle Kerberos ticket management, including initialization, authentication, and periodic ticket refresh. It provides a robust interface for integrating Kerberos authentication, ensuring secure and efficient credential management. #### Key Components 1. **KerberosConfig** (`kerberos_config.h` and `kerberos_config.cpp`): - This class encapsulates the configuration settings required for Kerberos authentication, such as principal, keytab path, and refresh intervals. - Provides methods to set and retrieve configuration parameters. 2. **KerberosTicketCache** (`kerberos_ticket_cache.h` and `kerberos_ticket_cache.cpp`): - Manages the Kerberos ticket cache, including initialization, login, and periodic refresh of tickets. - Supports operations like writing to the ticket cache and checking if a refresh is needed. - Utilizes a background thread to periodically refresh tickets based on configured intervals. - The default cache file will be written in `/tmp` dir, but can be modified using `kerberos_ccache_path` in be.conf 3. **KerberosTicketMgr** (`kerberos_ticket_mgr.h` and `kerberos_ticket_mgr.cpp`): - Acts as a manager for multiple Kerberos ticket caches, handling their lifecycle, including creation, access, and cleanup. - Provides methods to get or set ticket caches and retrieve cache file paths. - Includes a background thread for cleaning up expired ticket caches every 1 hour. If a cache is longer being referenced, it will be removed. 4. **HdfsMgr** - A simple and new class to manager the hdfs fs handler. - It replace the old `HdfsHandlerCache` - It will check HdfsHandler every 1 hour, and remove unused HdfsHandler after 24 hours. #### Mainly Changes 1. Introduce a comprehensive kerberos ticket cache management on BE side 1. Use ticket cache path instead of principal and keytab to do the kerberos authentication of libhdfs. 2. Fix the issue that `kerberos_krb5_conf_path` in be.conf does not take effect. 3. Add a new system table `backend_kerberos_ticket_cache`, to view the krb ticket cache of each backend: ``` Doris > select * from information_schema.backend_kerberos_ticket_cache\G *************************** 1. row *************************** BE_ID: 1738304534666 BE_IP: 172.20.32.136 PRINCIPAL: hdfs/[email protected] KEYTAB: /path/to/hdfs.keytab SERVICE_PRINCIPAL: krbtgt/[email protected] TICKET_CACHE_PATH: /tmp/doris_krb_ce93d5ebb2a6554c7ba9f43aee3a9e6c HASH_CODE: ce93d5ebb2a6554c7ba9f43aee3a9e6c START_TIME: 2025-02-01 00:08:26 EXPIRE_TIME: 2025-02-01 00:09:26 AUTH_TIME: 2025-02-01 00:08:26 REF_COUNT: 1 REFRESH_INTERVAL_SECOND: 3600 ``` #### Usage The user interface remains unchanged. 1. set krb5.conf path in be.conf `kerberos_krb5_conf_path`, default is `/etc/krb5.conf` 2. provide kerberos principal the keytab path as usual. #### Configurations be.conf 1. `kerberos_ccache_path` The dir where kerber ticket cache file saved. the file name as format `doris_krb_xxxx` 2. `kerberos_krb5_conf_path` The path of krb5.conf file 6. `kerberos_refresh_interval_second` The min interval to refresh a kerberos ticket cache file. default is 1h. 7. cleanup logic If the ticket cache is not used for 1 day, it will be deleted.
### What problem does this PR solve? add more hudi jni test cases. These tests depends on apache#47192 and part of apache#47299(the jni-util part)
…che#47913) ### What problem does this PR solve? Related PR: apache#47299 Problem Summary: The master branch only support java 17+, so should remote all `JAVA_OPTS` and use `JAVA_OPTS_FOR_JDK_17`
### What problem does this PR solve? add more hudi jni test cases. These tests depends on apache#47192 and part of apache#47299(the jni-util part)
### What problem does this PR solve? Introduced from #47299 the `SetEnvIfNecessary` may be called multiple times, and in #47299, we changed `setenv("LIBHDFS_OPTS", libhdfs_opts.c_str(), 0);` to `setenv("LIBHDFS_OPTS", libhdfs_opts.c_str(), 1);` so it will add `krb5 path` at the end of `LIBHDFS_OPTS` and set it every time, so `LIBHDFS_OPTS` becomes longer and longer. This PR fix this issue by calling `SetEnvIfNecessary` only once
### What problem does this PR solve? Introduced from #47299 the `SetEnvIfNecessary` may be called multiple times, and in #47299, we changed `setenv("LIBHDFS_OPTS", libhdfs_opts.c_str(), 0);` to `setenv("LIBHDFS_OPTS", libhdfs_opts.c_str(), 1);` so it will add `krb5 path` at the end of `LIBHDFS_OPTS` and set it every time, so `LIBHDFS_OPTS` becomes longer and longer. This PR fix this issue by calling `SetEnvIfNecessary` only once
### What problem does this PR solve? Introduced from apache#47299 the `SetEnvIfNecessary` may be called multiple times, and in apache#47299, we changed `setenv("LIBHDFS_OPTS", libhdfs_opts.c_str(), 0);` to `setenv("LIBHDFS_OPTS", libhdfs_opts.c_str(), 1);` so it will add `krb5 path` at the end of `LIBHDFS_OPTS` and set it every time, so `LIBHDFS_OPTS` becomes longer and longer. This PR fix this issue by calling `SetEnvIfNecessary` only once
…kerberos ticket. (apache#47826) ### What problem does this PR solve? Related PR: apache#47299 Problem Summary: fix the `KerberosTicketEntry entry` initialization to enable compile pass.
### What problem does this PR solve? Introduced from apache#47299 the `SetEnvIfNecessary` may be called multiple times, and in apache#47299, we changed `setenv("LIBHDFS_OPTS", libhdfs_opts.c_str(), 0);` to `setenv("LIBHDFS_OPTS", libhdfs_opts.c_str(), 1);` so it will add `krb5 path` at the end of `LIBHDFS_OPTS` and set it every time, so `LIBHDFS_OPTS` becomes longer and longer. This PR fix this issue by calling `SetEnvIfNecessary` only once
…kerberos ticket. (apache#47826) ### What problem does this PR solve? Related PR: apache#47299 Problem Summary: fix the `KerberosTicketEntry entry` initialization to enable compile pass.
…kerberos ticket. (apache#47826) ### What problem does this PR solve? Related PR: apache#47299 Problem Summary: fix the `KerberosTicketEntry entry` initialization to enable compile pass.
…stead of using kerberos ticket cache. (#48655) ### What problem does this PR solve? Related PR: #47299, #49181 This PR mainly changes: 1. Back to use principal and keytab to login kerberos instead of using kerberos ticket cache. Discard what I did in #47299. It looks like there are a lot of issue when using ticket cache in multi-kerberos env. So I abandoned that logic. 2. Config's default value Change the default value of related to hdfs file handle cache 1. `max_hdfs_file_handle_cache_num`: from 1000 to 20000 2. `max_hdfs_file_handle_cache_time_sec`: from 3600 to 28800 3. Fix a bug the cleanup thread of `FileHandleCache` is not working
What problem does this PR solve?
Overview
Previously, BE node use principal and keytab to do the kerberos authentication.
But only the modified hadoop libhdfs support authenticating in this way, the origin libhdfs
only support setting kerberos ticket cache path, or use system level kerberos authentication context.
This pull request introduces a comprehensive Kerberos authentication module for the BE.
The module is designed to handle Kerberos ticket management, including initialization, authentication, and periodic ticket refresh.
It provides a robust interface for integrating Kerberos authentication, ensuring secure and efficient credential management.
Key Components
KerberosConfig (
kerberos_config.h
andkerberos_config.cpp
):KerberosTicketCache (
kerberos_ticket_cache.h
andkerberos_ticket_cache.cpp
):/tmp
dir, but can be modified usingkerberos_ccache_path
in be.confKerberosTicketMgr (
kerberos_ticket_mgr.h
andkerberos_ticket_mgr.cpp
):HdfsMgr
HdfsHandlerCache
Mainly Changes
kerberos_krb5_conf_path
in be.conf does not take effect.backend_kerberos_ticket_cache
, to view the krb ticket cache of each backend:Usage
The user interface remains unchanged.
kerberos_krb5_conf_path
, default is/etc/krb5.conf
Configurations
be.conf
kerberos_ccache_path
The dir where kerber ticket cache file saved. the file name as format
doris_krb_xxxx
kerberos_krb5_conf_path
The path of krb5.conf file
kerberos_refresh_interval_second
The min interval to refresh a kerberos ticket cache file. default is 1h.
cleanup logic
If the ticket cache is not used for 1 day, it will be deleted.
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)